package com.taoyige.bean;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.taoyige.AppException;
import com.taoyige.common.JacksonJsonUtil;

/**
 * 商品实体类
 * @author peter
 * @version 1.0
 * @created 2014-11-13
 */

@JsonIgnoreProperties(ignoreUnknown=true)
public class Goods extends Entity{
	
	public final static String GOODS_ID = "id";
	public final static String GOODS_TITLE = "title";
	public final static String GOODS_PRICE = "price";
	public final static String GOODS_ORIGIN_PRICE = "oriPrice";
	public final static String GOODS_STORE_COUNT = "count";
	public final static String GOODS_CATEGORY = "category";
	public final static String GOODS_SOLD_VOLUME = "salesVolume";
	public final static String GOODS_DESCRIPTION = "description";
	public final static String GOODS_BANNER_IMAGE_URL = "bannerUrl";
	public final static String GOODS_LARGE_IMAGE_URL = "largeImageUrl";
	public final static String GOODS_NORMAL_IMAGE_URL = "normalImageUrl";
	public final static String GOODS_THUMB_IMAGE_URL = "thumbImageUrl";
	public final static String GOODS_DETAIL_IMAGE_URL = "detailsImageUrl";
	public final static String GOODS_FREIGHT = "freight";
	public final static String GOODS_START_TYPE = "startType";
	public final static String GOODS_SALE_START_TIME = "saleStartTime";
	public final static String GOODS_SALE_OFF_TIME = "saleOffTime";
	public final static String GOODS_TIMESTAMP = "timestamp";
	public final static String GOODS_STATUS = "status";

	private String title;
	private Double price;
	private Double oriPrice;
	private String bannerUrl;
	private Integer count;
	private Integer salesVolume;
	private String category;
	private String description;
	private List<String> largeImageUrl;
	private List<String> normalImageUrl;
	private List<String> thumbImageUrl;
	private List<String> detailsImageUrl;
	private Double freight;
	
	private Date saleStartTime;
	private Date saleOffTime;
	private Date timestamp;
	private Date serverTime;
	
	private String startType;
	
	private String status;
	
	enum GoodsStatus{
		STORE("1"),READY("2"),ONSALE("3");
		private String code;
		private GoodsStatus(String code){
			this.code=code;
		}
		public String toString(){
			return String.valueOf(this.code);
		}
	}
	
	
	public String getStartType() {
		return startType;
	}

	public void setStartType(String startType) {
		this.startType = startType;
	}
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getServerTime() {
		return serverTime;
	}

	public void setServerTime(Date serverTime) {
		this.serverTime = serverTime;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Double getOriPrice() {
		return oriPrice;
	}

	public void setOriPrice(Double oriPrice) {
		this.oriPrice = oriPrice;
	}

	public String getBannerUrl() {
		return bannerUrl;
	}

	public void setBannerUrl(String bannerUrl) {
		this.bannerUrl = bannerUrl;
	}

	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	public Integer getSalesVolume() {
		return salesVolume;
	}

	public void setSalesVolume(Integer salesVolume) {
		this.salesVolume = salesVolume;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<String> getLargeImageUrl() {
		return largeImageUrl;
	}

	public void setLargeImageUrl(List<String> largeImageUrl) {
		this.largeImageUrl = largeImageUrl;
	}

	public List<String> getNormalImageUrl() {
		return normalImageUrl;
	}

	public void setNormalImageUrl(List<String> normalImageUrl) {
		this.normalImageUrl = normalImageUrl;
	}

	public List<String> getThumbImageUrl() {
		return thumbImageUrl;
	}

	public void setThumbImageUrl(List<String> thumbImageUrl) {
		this.thumbImageUrl = thumbImageUrl;
	}

	public List<String> getDetailsImageUrl() {
		return detailsImageUrl;
	}

	public void setDetailsImageUrl(List<String> detailsImageUrl) {
		this.detailsImageUrl = detailsImageUrl;
	}

	public Double getFreight() {
		return freight;
	}

	public void setFreight(Double freight) {
		this.freight = freight;
	}

	public Date getSaleStartTime() {
		return saleStartTime;
	}

	public void setSaleStartTime(Date saleStartTime) {
		this.saleStartTime = saleStartTime;
	}

	public Date getSaleOffTime() {
		return saleOffTime;
	}

	public void setSaleOffTime(Date saleOffTime) {
		this.saleOffTime = saleOffTime;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public static Goods  parse(InputStream ins) throws Exception {
		Goods goods = (Goods) JacksonJsonUtil.jsonToBean(ins, Goods.class);
		return goods;
	}
	
	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.SHORT_PREFIX_STYLE);
	}
	
}
